Skip to main content

Response Processing Rules

Response Processing Rules (RPR) are multi-purpose and allow the implementation of stateful test cases and anomaly detection mechanisms.

Response Processing Rules can observe and extract data from the response and store it in Session Variables for later use. The extracted data is accessible from within Message Templates, Condition Group Rules and Callbacks, which allows the implementation of stateful test cases and testing of complex protocols.

Using RPRs, we can also detect the abnormal behaviour of the target under test. We can use one or more RPRs to define (most often) the expected behaviour of the target under test and detect irregularities during testing by analysing the response received. If the observed behaviour is not compliant with the configured rules, GUARDARA raises it as an issue.

Comparables

A Response Processing Rule operates with two Comparables. A Comparable can represent a pre-defined static value or dynamic data that GUARDARA resolves during test run time. A Comparable can be many things, such as session or environment variables, strings, numbers, regular expressions or data sent or received.

For example, a dynamically resolved Comparable (A) could be the entire response or just part of the response received from the target under test. It could, for example, represent an HTTP response code. A pre-defined, static Comparable (B) could represent the number 500. Using these two Comparables, we could set up a Response Processing Rule to compare Comparable A with Comparable B to detect 500 Internal Errors when testing web services.

We can define Comparables using the Flow Template Designer by selecting View > Comparables from the editor menu.

We define what a Comparable represents using a set of fields. These fields are discussed below.

Comparable Name

The Comparable Name field should be a short but descriptive, unique name. This name will be shown when configuring Response Processing Rules.

Subject

The Subject field defines what the Comparable represents. It can be a variety of things we will discuss in a second. The options provided by the Scope field depend on the value of the Subject field. Please note the Scope field is not visible until a Subject is selected.

The individual Subjects and related configuration options are discussed below.

Sent

The Sent subject results in the Comparable to resolve to something we have sent or a particular attribute of the data sent. When selected, the Scope field will offer the following options:

ScopeDescription
Field ValueWhen selected, a Field selector appears that allows selecting from fields exposed in the session by Message Templates within the test flow. Fields can be exposed in the session by setting their Expose in Session advanced property in the Message Template Designer to Yes. Once a Field is selected, the Attribute field appears. It allows defining which attribute of the Field the Comparable should resolve to. This could be the raw or rendered value or length of the Field’s value.
RequestWhen selected, an Attribute selector appears that allows selecting Length, which represents the entire length of the data (test case) sent to the target, or Timestamp, which is the timestamp of when the test case was transmitted to the target.

Received

The Received subject results in the Comparable to resolve to something we have received from the test target or a particular attribute of the data received. When selected, the Scope field will offer the following options:

ScopeDescription
Field ValueWhen selected, a Field selector appears that allows providing a regular expression. GUARDARA uses this regular expression to extract data from the target’s response. We have to use capture groups within the regular expression so that GUARDARA knows precisely what to extract. For example, we could set the Field to (.*) to resolve the comparable to the entire response. If we wanted to extract, for example, a session ID from an HTTP response that is returned as a Cookie, we could do use a regular expression similar to this: .*Set-Cookie: SESSIONID=([a-zA-Z0-9]*);.*.
RequestWhen selected, an Attribute selector appears that allows selecting Length, which represents the entire length of the data received, or Timestamp, which is the timestamp of when the data was received.

Session Variable

The Session Variable subject results in the Comparable to resolve to the value of a Session Variable defined in the Variable Collection.

Environment Variable

The Environment Variable subject results in the Comparable to resolve to the value of an environment variable defined on the system the Engine is running on.

Number

The Number subject results in the Comparable to resolve to the integer value defined using the Value field.

String

The Number subject results in the Comparable to resolve to the string value defined using the Value field.

Regular Expression

The Regular Expression subject results in the Comparable to resolve to the string value defined using the Regular Expression field.

Creating Processing Rules

You can create Processing Rules using the Flow Template Designer by selecting View > Response Processing Rules from the editor menu. It is expected for at least two Comparables to be available to set up a Response Processing Rule.

To add a new rule, we have to click the Add button (+) in the Processing Rules window. From this point on, the process is the following.

  1. Enter a short but descriptive, unique name for the rule in the Rule Name field.
  2. (Optional) Add a description that tells the purpose of the processing rule.
  3. Select the first Comparable using the Comparable field that appears once the Rule Name is set.
  4. Configure the Expected and To fields according to your specific requirements.
  5. Select the second Comparable using the Comparable field.
  6. Using the Otherwise field, select what should happen if the condition defined by the rule is not met.
  7. Click the Save button to save the rule.

The Otherwise field options are summarised in the table below.

Rule ActionDescription
ContinueContinue as if nothing happened.
ReportCreate an issue entry in the report.
SkipSkip to the next iteration.
Skip and ReportSkip to the next iteration and create an issue entry in the report.
NextSkip to the following field.
Next and ReportSkip to the following field and create an issue entry in the report.
PausePause the test.
Pause and ReportPause the test and create an issue entry in the report.
TerminateTerminate the test.
Terminate and ReportTerminate the test and create an issue entry in the report.

Enabling Processing Rules

Response Processing Rules can be assigned to Receive actions within the Test Flow Template. It is as easy as:

  1. Open the Receive action by clicking on the Action Details Button
  2. Click on the Add New Rule button to add a new processing rule to the Action
  3. Select the Processing Rule to add using the drop-down menu, then click the Add button

Disabling Processing Rules

To remove a processing rule assigned to a Receive action:

  1. Open the Receive action by clicking on the Action Details Button
  2. Select the Processing Rule to be removed using the checkbox next to its name
  3. Click the Trash icon to remove the rule